global.elevator_state = 'opening'
sound_stop(snd_moving)
sound_play(snd_opendoor)
    
with (obj_leftdoor)
{
    path_start(path_rtol, global.opening_speed, 0, false)
}

with (obj_rightdoor)
{
    path_start(path_ltor, global.opening_speed, 0, false)
}

global.current_floor -= 1

if (global.current_floor == 1)
{
    // end game.
    global.game_state = 'pausing'
    
    with (obj_start_button)
    {
        visible = 1
        x = room_width / 2
        y = room_height - 96
    }
}
else if (global.current_floor != global.start_floor)
{
    for (i = 0; i < global.new_comers_count; i += 1)
    {
        with (global.new_comers[i])
        {
            if state == 'created' or state == 'badsmell'
            {
                instance_destroy()
            }
        }
    }
    
    global.new_comers_count = irandom_range(global.min_victim_count, global.max_victim_count)
    for (i = 0; i < global.new_comers_count; i += 1)
    {
        px = irandom_range(160-72,160+72)
        global.new_comers[i] = instance_create(px, 392, obj_victim)
    }
}

